<?php
namespace app\Http\Models;
use Illuminate\Database\Eloquent\Model;

/**
 * Created by PhpStorm.
 * User: wangyongqiang
 * Date: 2017/7/5 19:57
 */
class AuthGroupModel extends Model{

    protected $connection = 'db_main';
    protected $table = 'wp_auth_group';

    //protected $fillable = ["guid", "username", "password", "mobile", "reg_time", "reg_ip", "verify_mobile", "is_experience"];

    public $timestamps = false;

    /**
     * 获取用户VIP权限
     * @param int $uid
     * @return bool
     */
    public static function checkWhiteList($uid = 0){
        static $whiteUids;
        $chkUser = false;
        if(!$whiteUids) {
            if($uid == 1){
                $chkUser = true;
            } else {
                $groupId = AuthGroupAccessModel::getGroupIdByUid($uid);
                if($groupId) {
                    $descInfo = self::where( array('id'=>$groupId) )->value("description");
                    if(in_array($descInfo, array('ADMIN', 'TEST', 'PRODUCT', 'DEVELOPMENT', 'COMMERCE'))){
                        $chkUser = true;
                    }
                }
            }
        }
        return $chkUser;
    }

}